﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using smsclictr.automation;
using Opalis.QuickIntegrationKit;
using System.Management;

namespace OpalisAddOn.WOL
{
    /// <summary>
    /// WakeOnLan Feature
    /// </summary>
    [OpalisObject("WakeUp", Description = "WakeUp Computer by sending a WOL package", ShowFilters = false)]
    public class WakeUp : IOpalisObject
    {
        public void Design(IOpalisDesigner designer)
        {
            designer.AddInput("MAC Address");

            designer.AddInput("BroadcastIP").NotRequired();
            designer.AddInput("Port").NotRequired();
        }

        public void Execute(IOpalisRequest request, IOpalisResponse response)
        {
            if (request.Inputs.Contains("BroadcastIP") & request.Inputs.Contains("Port"))
            {
                smsclictr.automation.WOL.WakeUp(System.Net.IPAddress.Parse(request.Inputs["BroadcastIP"].AsString()), int.Parse(request.Inputs["Port"].AsString()), request.Inputs["MAC Address"].AsString());
            }
            else
            {
                smsclictr.automation.WOL.WakeUp(request.Inputs["MAC Address"].AsString());
            }
        }
    }
}